#include <omp.h>
#include <stdio.h>
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {

    // aufgabe 21
    /*
    void prefix (int n, double* x, double* y)
    {
    double *xs=new double[n+1];
    double *ys=new double[n+1];
     y[1]=x[1];
    if (n>1)
     {
    #pragma omp parallel for
     for (int i=1;i<=n/2;i++) xs[i]=x[2*i-1]+x[2*i];
     prefix(n/2, xs, ys);
    #pragma omp parallel for
     for (int i=1;i<=n/2;i++) y[2*i]=ys[i];
    #pragma omp parallel for
     for (int i=1;i<=n/2;i++) y[2*i+1]=ys[i]+x[2*i+1];
     }
    }*/


    // aufgabe 22
    /*
    const int n = 4;
    double y[n], x[n], z[n];

    // init 0.1.2.3...
    for(int i=0; i<n; i++){
        y[i] = x[i] = i;
    }

    double sum_local = 0;
    double sum = 0;
    #pragma omp parallel shared(x,y,sum) private(sum_local)
    {
        #pragma omp for reduction(+:sum)
        for (int i=0; i<n; i++)
            sum = sum + x[i] * y[i]; // form per-thread local sum
    }

    cout << sum << endl;

    */



    //double Skalar_Produkt(x,y)
/*    const int n = 4;
    double y[n], x[n], z[n];

    // init
    for(int i=0; i<n; i++){
        y[i] = x[i] = i;
        z[i] = 0;
    }


    #pragma omp parallel for
    for (int i=0;i<=n-1;i++) //parallel auf n Proz.
        z[i]=x[i]*y[i];

    int d = n;
    do {
        d = d / 2;
        #pragma omp parallel for
        for (int i=0;i<=d-1;i++) // parallel auf n Prozessoren
            z[i] = z[2 * i] +z[2 * i + 1];

    } while (d > 1);

    cout << z[0] << endl; */




    return 0;
}
